//
//  ST_UpLiveSquareOptionsBackupsController.swift
//  btvideo
//
//  Created by mac on 2021/3/19.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyAttributes


enum ST_RiseLiveValueAlert {
    case old,party
    
    var jsonKey:String{
        switch self {
        case .old:
            return "up_live_rank"
        case .party:
            return "up_party_rank"
        }
    }
}

//MARK: - Alert
class ST_RiseLiveValueAlertController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        view.addSubview(root_view)
        root_view.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.equalTo(300)
            switch keyNum{
            case .old:
                make.height.equalTo(352)
            case .party:
                make.height.equalTo(250)
            }
        }
        
        
        root_view.addSubview(pushBtn)
        pushBtn.snp.makeConstraints { (make) in
            make.width.equalTo(200)
            make.centerX.equalToSuperview()
            make.height.equalTo(44)
            make.bottom.equalToSuperview().offset(-30)
        }
        
        root_view.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.height.equalTo(28)
            make.top.equalToSuperview().offset(40)
        }
        
        root_view.addSubview(content_label1)
        content_label1.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.left.equalToSuperview().offset(25)
            make.right.equalToSuperview().offset(-25)
            make.top.equalToSuperview().offset(75)
        }
        
        root_view.addSubview(content_label2)
        content_label2.snp.makeConstraints { (make) in
            make.left.right.equalTo(content_label1)
            make.top.equalTo(content_label1.snp.bottom).offset(10)
        }
        
        root_view.addSubview(contentLabel3)
        contentLabel3.snp.makeConstraints { (make) in
            make.left.right.equalTo(content_label2)
            make.top.equalTo(content_label2.snp.bottom).offset(10)
        }
        
        root_view.addSubview(contentLabel4)
        contentLabel4.snp.makeConstraints { (make) in
            make.left.right.equalTo(contentLabel3)
            make.top.equalTo(contentLabel3.snp.bottom).offset(10)
        }
    }
    
    
    
    
//    MARK: - Properties
    
    fileprivate lazy var root_view:UIView = {
        let control = UIView()
        control.backgroundColor = .white
        control.cornerRadius = 16
        return control
    }()
    
    fileprivate lazy var pushBtn:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
       control.setTitleForAllStates("我知道啦")
        control.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.semibold)
        control.backgroundColor = UIColor.init(hexString: "#FEC207")
        control.setTitleColorForAllStates(UIColor.white)
        control.cornerRadius = 22
        control.add_touch_up(insideTarget: self, action: #selector(close_handle))
        return control
    }()
    
    fileprivate lazy var titleLabel:UILabel = {
        let label = UILabel()
        let attrString = NSMutableAttributedString(string: SCComponets.rich_text_storage_component.json[keyNum.jsonKey]["content"].stringValue)
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.medium),.foregroundColor: UIColor.init(hex: 0x333333)!]
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        label.attributedText = attrString
        return label
    }()
    
    
    
    var keyNum = ST_RiseLiveValueAlert.old
    
    
    

    fileprivate lazy var content_label1:UILabel = {
        
        let label = UILabel()
        
        label.numberOfLines = 0
        
        let str = SCComponets.rich_text_storage_component.json[keyNum.jsonKey]["tips"][0].stringValue
        
        let attrString = NSMutableAttributedString(string: str)
        
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular),.foregroundColor: UIColor.init(hex: 0x61666F)!,.paragraphStyle:NSParagraphStyle.create_line_spacing_paragraph_style(lineSpacing: 3)]
        
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        
        label.attributedText = attrString
        
        return label
    }()
    
    fileprivate lazy var content_label2:UILabel = {
        
        let label = UILabel()
        
        label.numberOfLines = 0
        
        let str = SCComponets.rich_text_storage_component.json[keyNum.jsonKey]["tips"][1].stringValue
        
        let attrString = NSMutableAttributedString(string: str)
        
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular),.foregroundColor: UIColor.init(hex: 0x61666F)!,.paragraphStyle:NSParagraphStyle.create_line_spacing_paragraph_style(lineSpacing: 3)]
        
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        
        label.attributedText = attrString
        
        return label
    }()
    
    fileprivate lazy var contentLabel3:UILabel = {
        
        let label = UILabel()
        
        label.numberOfLines = 0
        
        let str = SCComponets.rich_text_storage_component.json[keyNum.jsonKey]["tips"][2].stringValue
        
        let attrString = NSMutableAttributedString(string: str)
        
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular),.foregroundColor: UIColor.init(hex: 0x61666F)!,.paragraphStyle:NSParagraphStyle.create_line_spacing_paragraph_style(lineSpacing: 3)]
        
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        
        label.attributedText = attrString
        
        return label
    }()
    
    
    fileprivate lazy var contentLabel4:UILabel = {
        
        let label = UILabel()
        
        label.numberOfLines = 0
        
        let str = SCComponets.rich_text_storage_component.json[keyNum.jsonKey]["tips"][3].stringValue
        
        let attrString = NSMutableAttributedString(string: str)
        
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular),.foregroundColor: UIColor.init(hex: 0x61666F)!,.paragraphStyle:NSParagraphStyle.create_line_spacing_paragraph_style(lineSpacing: 3)]
        
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        
        label.attributedText = attrString
        
        return label
    }()
    
}

extension ST_RiseLiveValueAlertController{
    
    
    
    @objc fileprivate func close_handle(){
        
        goback_previous_controller()
        
    }
}
